package v3.chapter3.firstNotify;

public class Run {
	private String lock = new String("");
	private Runnable runnableA = new Runnable() {
		@Override
		public void run() {
			try {
				synchronized (lock) {
					System.out.println("begin wait");
					lock.wait();
					System.out.println("end wait");
				}
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	};

	private Runnable runnableB = new Runnable() {
		@Override
		public void run() {

			synchronized (lock) {
				System.out.println("begin notify");
				lock.notify();
				System.out.println("end notify");
			}
		}
	};
	
	public static void main(String[] args) throws InterruptedException {
		Run myrun=new Run();
		Thread b=new Thread(myrun.runnableB);
		b.start();
		Thread.sleep(1000);  
		Thread a=new Thread(myrun.runnableA);
		a.start();
	}
	
}  